
package com.kalvan.core.mybatis.sharding;

import com.kalvan.core.mybatis.provider.ShardingProvider;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import tk.mybatis.mapper.annotation.RegisterMapper;
import tk.mybatis.mapper.common.*;
import tk.mybatis.mapper.common.base.delete.DeleteMapper;
import tk.mybatis.mapper.common.base.insert.InsertMapper;
import tk.mybatis.mapper.common.base.insert.InsertSelectiveMapper;
import tk.mybatis.mapper.common.base.select.SelectAllMapper;
import tk.mybatis.mapper.common.base.select.SelectCountMapper;
import tk.mybatis.mapper.common.base.select.SelectMapper;
import tk.mybatis.mapper.common.base.select.SelectOneMapper;

/**
 * 抽数据封装数据方法<br>
 * 抽取数据时才使用该Mapper
 * <p>
 * Mapper<T>, MySqlMapper<T>,
 * ConditionMapper<T>
 *
 * @author chenliang
 * @version 2018年11月25日
 * @see ShardingMapper
 * @since
 */
@RegisterMapper
public interface ShardingMapper<T> extends
        SelectOneMapper<T>, SelectMapper<T>, SelectAllMapper<T>, SelectCountMapper<T>,
        InsertMapper<T>, InsertSelectiveMapper<T>,
        DeleteMapper<T>,
        ExampleMapper<T>, RowBoundsMapper<T>,
        MySqlMapper<T>, ConditionMapper<T>,
        Marker {
    /**
     * 根据分片唯一键查询
     *
     * @param var1
     * @return
     */
    @SelectProvider(
            type = ShardingProvider.class,
            method = "dynamicSQL"
    )
    T selectByUk(Object var1);


    /**
     * 根据分片唯一键查询
     *
     * @param var1
     * @return
     */
    @SelectProvider(
            type = ShardingProvider.class,
            method = "dynamicSQL"
    )
    boolean existsWithUk(Object var1);


//    /**
//     * 根据分片唯一键更新所有字段
//     *
//     * @param var1
//     * @return
//     */
//    @UpdateProvider(
//            type = ShardingProvider.class,
//            method = "dynamicSQL"
//    )
//    int updateByUk(T obj);


    /**
     * 根据分片唯一键更新
     *
     * @param var1
     * @return
     */
    @UpdateProvider(
            type = ShardingProvider.class,
            method = "dynamicSQL"
    )
    int updateByUkSelective(T var1);

    /**
     * 根据分片唯一键删除
     *
     * @param var1
     * @return
     */
    @DeleteProvider(
            type = ShardingProvider.class,
            method = "dynamicSQL"
    )
    int deleteByUk(Object var1);


}
